package com.tanhua.server.controller;

import com.tanhua.server.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/comments")
public class CommentController {

    @Autowired
    private CommentService commentService;
    /**
     * 评论列表
     * GET /comments
     */
    @GetMapping
    public ResponseEntity findCommentsList(String movementId,int page,int pagesize){
        return commentService.findCommentsList(movementId,page,pagesize);
    }
    /**
     * 单条动态-发表评论
     * POST /comments
     */
    @PostMapping
    public ResponseEntity saveComment(@RequestBody Map map){
        String publishId = (String) map.get("movementId");
        String content = (String) map.get("comment");
        return commentService.saveComment(publishId,content);
    }
}
